import bus from '@/bus'
import { renderButton } from '@/util'
let data = {
  status: 'pass',
  totalItem: 1,
  pageSize: window.$pageSize,
  currentPage: 1,
  form: {
    policyName: ''
  },
  columns: [{
    title: '规则名称',
    key: 'policyName',
    align: 'left',
    minWidth: 150
  }, {
    renderHeader: (h, p) => {
      let inner = h('div', [
        h('span', '有效天数'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      let slot = h('div', {
        slot: 'content'
      }, [
        h('p', '从经销商扫码出库到门店入库之间'),
        h('p', '的时间最长不可超过以下天数')
      ])
      return h('Tooltip', {
        props: {
          placement: 'top',
          transfer: true
        }
      }, [inner, slot])
    },
    key: 'effectiveDays',
    align: 'right',
    minWidth: 150
  }, {
    renderHeader: (h, p) => {
      let inner = h('div', [
        h('span', '定位距离(米)'),
        h('Icon', {
          props: {
            type: 'ios-help-circle',
            size: 18
          }
        })
      ])
      let slot = h('div', {
        slot: 'content'
      }, [
        h('p', '门店扫码入库时可允许'),
        h('p', '偏移门店定位最大的距离')
      ])
      return h('Tooltip', {
        props: {
          placement: 'top',
          transfer: true
        }
      }, [inner, slot])
    },
    key: 'distance',
    align: 'right',
    minWidth: 100
  }, {
    title: '省市',
    key: 'provinceName',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      let provinceName = params.row.provinceName
      let cityName = params.row.cityName
      if (provinceName) {
        if (cityName) {
          return h('div', provinceName + cityName)
        } else {
          return h('div', provinceName)
        }
      } else {
        return h('div', '全国')
      }
    }
  }, {
    title: '操作',
    align: 'right',
    minWidth: 180,
    render: (h, params) => {
      return (
        <div>
          { renderButton(h, { text: '编辑', type: 'primary'},
            ()=>{ bus.$emit('onEdit', params.row.id)})}
          { renderButton(h, { text: '删除', type: 'warning', disabled: params.row.isSystem == true},
            ()=>{ bus.$emit('onDelete',  params.row.id, params.row.name, params.index)})}
        </div>
      )
    }
  }],
  data: []
}
export default data